GO
IF OBJECT_ID ( 'createEducationFilter', 'P' ) IS NOT NULL 
    DROP PROCEDURE [dbo].[createEducationFilter];
GO
CREATE PROCEDURE [dbo].[createEducationFilter]
	@FilterName VARCHAR(40)
AS
BEGIN
	DECLARE @FilterId INT
    INSERT INTO [FILTER] ([NAME], [TABLE_NAME], [TYPE])
		VALUES(@FilterName, 'Education', 'System')
	SET @FilterId = @@IDENTITY;
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationId', 'Education', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationStatus', 'Education', 'Status', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationMark', 'Education', 'Mark', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'ModuleId', 'Module', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'ModuleName', 'Module', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'ModuleDescription', 'Module', 'Description', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'ModuleHoldingType', 'Module', 'HoldingType', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'ModuleParticipantType', 'Module', 'ParticipantType', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserId', 'User', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserLogin', 'User', 'Login', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserName', 'User', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserSurname', 'User', 'Surname', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserMiddleName', 'User', 'MiddleName', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserEmail', 'User', 'Email', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserTelephon', 'User', 'Telephon', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupId', 'Group', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupName', 'Group', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupDescription', 'Group', 'Description', 'Text')
END
GO
